﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Mimoza.PluginsLayer
{
    public class PluginDataGeneric<T> where T : class, new()
    {
        public string Serialize()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            TextWriter text = new StringWriter();
            serializer.Serialize(text, this);
            return text.ToString();
        }

        public static T Deserialize(string data)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(T));
            using (TextReader text = new StringReader(data))
            {
                return deserializer.Deserialize(text) as T;
            }
        }

    }
}
